console.log(".........publicHeader...........");
let publicHeader = new Vue({
    //element
    el: "#publicHeaderApp",
    data: {
        bookTypes: [],
        currentAccount:'',
        keyword:''
    },
    methods: {
        initBookTypes() {
            //局部变量,便于get方法中调用vue对象
            let _this = this;
            $.get("/booktype/all", function (data) {
                _this.bookTypes = data;
            })
        }
        ,
        initCurrentAccount(){
            let _this=this;
            $.get("/user/currentAccount",function (data) {
                _this.currentAccount=data;
            })
        }
        ,
        toSearch(){
            //搜索关键字不能为空
            if(!this.keyword){
                alert("搜索关键词不能为空")
                return;
            }

            location.href="/book/search?keyword="+this.keyword;
        }
    },
    //vue生命周期中调用
    created() {
        this.initBookTypes();
        this.initCurrentAccount();
    }
});
